import threading
import time, random


# basic threads
def action():
    for i in range(4):
        time.sleep(random.randrange(0, 5))
        print(time.time(), threading.currentThread().getName())


list_t = []
for i in range(5):
    t = threading.Thread(target=action)
    t.setDaemon(True)  # 子线程为守护线程，主线程一旦结束，子线程也结束
    t.start()
    list_t.append(t)
# what mean block main thread? Here is the way bolck until main thread finished
for t in list_t:
    t.join()  # 逐个阻塞主线程

print('complete!')
